//
//  HomeCollectoinViewLayout.swift
//  PhotoBrowser
//
//  Created by Apple on 16/4/27.
//  Copyright © 2016年 Apple. All rights reserved.
//

import UIKit

class HomeCollectoinViewLayout: UICollectionViewFlowLayout {
    
    override func prepareLayout() {
        
        super.prepareLayout()

        // 定义常量
        let cols : CGFloat = 3
        let margin : CGFloat = 10

        // 计算 itemWH
        let itemWH : CGFloat = 1.0 * (UIScreen.mainScreen().bounds.width - (cols + 1) * margin) / cols

        // 设置布局
        itemSize = CGSize(width: itemWH, height: itemWH)
        minimumInteritemSpacing = margin
        minimumLineSpacing = margin

        // 设置 collectionView 的属性
        collectionView?.contentInset = UIEdgeInsets(top: margin + 64, left: margin, bottom: margin, right: margin)
    }
}
